/*
 * LineEvaluationSource.java - ScriptME
 * 
 * Copyright (c) 2009 Cesar Henriques <cesar at alttab.com.ar>.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v2.1
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * 
 * Based on FESI Project
 * 
 * Contributors:
 * 	Jean-Marc Lugrin - initial API and implementation
 * 	Cesar Henriques <cesar at alttab.com.ar> - J2ME Porting and Extensions
 */
package org.scriptme.ecmascript.interpreter;

/**
 * Add line number to an evaluation source.
 */
public class LineEvaluationSource extends EvaluationSource {

	/** The line number. */
	private int theLineNumber;

	/**
	 * Create a source description being the line number of a previous
	 * description.
	 * 
	 * @param theLineNumber
	 *            Describe the line number
	 * @param previousSource
	 *            Describe the calling source
	 */
	public LineEvaluationSource(int theLineNumber,
			EvaluationSource previousSource) {
		super(previousSource);
		this.theLineNumber = theLineNumber;
	}

	/**
	 * Return the string describing the line number.
	 * 
	 * @return the evaluation source text
	 */
	protected String getEvaluationSourceText() {
		return "at line " + theLineNumber + " "
				+ previousSource.getEvaluationSourceText();
	}

	/**
	 * Get the line number of the error if possible.
	 * 
	 * @return the line number
	 */
	public int getLineNumber() {
		return theLineNumber;
	}
}
